﻿namespace OA.DAL.Migrations
{
    using OA.Models;
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<OA.DAL.OADbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
            ContextKey = "OA.DAL.OADbContext";
        }

        protected override void Seed(OA.DAL.OADbContext context)
        {
            if (!context.SysRoles.Any())
            {
                var role = new SysRole() { Name = "管理员", Remark = "超级管理员" };
                var user = new SysPerson() { Name = "张总", LoginName = "admin", LoginPwd = "admin", OrgId = 1 };
                role.SysPersons = new List<SysPerson> { user };
                context.SysRoles.Add(role);
                context.SaveChanges();
            }
        }
    }
}
